package com.itdfq.loginuser.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @Author: GodChin
 * @Date: 2021/8/23 8:56
 * @Blog: itdfq.com
 * @QQ: 909256107
 * @Description:
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
public class Result {
    //是否成功
    private Boolean success;
    //状态码
    private Integer code;
    //提示信息
    private String msg;
    //数据
    private Object data;

    public Result() {
    }

    public void clean() {
        this.setMsg(null);
        this.setCode(null);
        this.setData(null);
        this.setSuccess(null);
    }

    public static Result success(Object data) {

        return new Result(true, 100, null, data);
    }

    public static Result fail(String msg) {
        return new Result(false, 999, msg, null);
    }

    public boolean isSuccess(){
        return success;
    }
}
